﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Three
{
    internal class Food:GameObject
    {
        Snake s;
        public Food(Snake snake) 
        {
            s = snake;
            RandomPos();
        }

        public override void Draw()
        {
            Console.SetCursorPosition(pos.x, pos.y);
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("■");
        }

        public void RandomPos()
        { 
            Random r = new Random();
            int x = r.Next(1, Game.w/2-1)*2;
            int y = r.Next(1, Game.h - 3);
            pos = new Position(x, y);
            if (s.CheckSamePos(pos))
            {
                RandomPos();
            }
        }

    }
}
